import { HttpException, HttpStatus } from '@nestjs/common';

export const halt = (
  message: string = '请求错误',
  code: HttpStatus = HttpStatus.BAD_REQUEST,
) => {
  throw new HttpException(message, code);
};

export const ok = (
  data: any = null,
  code: HttpStatus = HttpStatus.OK,
  message: string = '成功',
) => {
  return {
    code,
    success: true,
    message,
    data,
  };
};
